package com.jsd2412.backend.room.controller;

import com.jsd2412.backend.base.response.JsonResult;
import com.jsd2412.backend.room.pojo.dto.RoomQuery;
import com.jsd2412.backend.room.pojo.dto.RoomSaveParam;
import com.jsd2412.backend.room.pojo.vo.RoomVO;
import com.jsd2412.backend.room.service.RoomService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "房间管理")
@RestController
@Slf4j
@RequestMapping("/v1/room/")
public class RoomController {
    @Autowired
    private RoomService roomService;


    @PostMapping("save")
    public JsonResult save(RoomSaveParam roomSaveParam) {
        log.debug("保存房间业务:{}", roomSaveParam);
        roomService.save(roomSaveParam);
        return JsonResult.ok();
    }
    @PostMapping("delete/{id}")
    public JsonResult delete(@PathVariable Integer id) {
        log.debug("删除房间业务:{}", id);
        roomService.delete(id);
        return JsonResult.ok();
    }
    @GetMapping("select")
    public JsonResult select(RoomQuery roomQuery) {
        log.debug("查询房间业务:{}", roomQuery);
        List<RoomVO> list = roomService.select(roomQuery);
        return JsonResult.ok(list);
    }

}
